const mongoose = require('mongoose');
const { dbUri } = require('../config/config.default')

// 链接数据库
mongoose.connect(dbUri, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

const db = mongoose.connection

db.on('error', function () {
  console.log('error')
})

db.once('open', function () {
  console.log('open')
})

module.exports = {
  User: mongoose.model('User', require('./user'))
}
